<?php
// +----------------------------------------------------------------------
// | Description: Categories
// +----------------------------------------------------------------------
// | Author: orchief
// +----------------------------------------------------------------------
// | Date: 2018-01-24 14:27:02
// +----------------------------------------------------------------------

namespace app\client\controller;

use app\common\controller\Rest;
use com\MyTree;

class Categories extends Rest
{
    public $modelName = 'Category';
    public function _initialize()
    {
        parent::_initialize();
        // $this -> abort(!$this -> isClient, 'Permission denied', 403);
    }

    public function treeData()
    {
        $data = self::$model->getAllData();

        // $data = [
        //     ['id' => 1, 'label' => 1212, 'children' => [] ],
        //     ['id' => 2, 'label' => 1212, 'children' => [] ]
        // ];

        $tree = new MyTree($data);
        // p($tree -> tree());

        $this->jsonData($data);
    }
}
